package com.shopping.dev.common.util;

import tk.mybatis.mapper.util.StringUtil;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    public static final String WEB_FORMAT = "yyyy-MM-dd";
    public static Date stringToDate(String date, String fomat){
        if (StringUtil.isEmpty(fomat)){
            fomat = WEB_FORMAT;
        }
        DateFormat dataFormat = new SimpleDateFormat(fomat);
        Date data = null;
        try {
            data = dataFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return data;
    }
}
